﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="fullmap.aspx.cs" Inherits="weba.fullmap" %>

<!DOCTYPE html>



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ditumap</title>
    <style type="text/css">
        #container {
            height: 600px;
            width: 960px;
            float: left;
        }

        .ysa {
            float: left;
            width: 960px;
            vertical-align: middle;
        }
        .markerContentStyle{position:relative;}
        .markerContentStyle span{
            background-color: #FFFFFF;
            color: #FF1493;
            width: 80px;
            height: 15px;
            border: 2px solid #D8BFD8;
            FONT-FAMILY: 华文行楷;
            position: absolute;
            top: -15px;
            left: -30px;
            white-space: nowrap -webkit-border-radius:5px;
            border-radius: 5px;
            font-size: small;
        }
        .markerContentStyle span a {
             background-color: #FFFFFF;
            color: #FF1493;
             FONT-FAMILY: 华文行楷;
               font-size: small;
        }
    </style>
</head>
<body onload="initialize()">
    <form id="HtmlForm" runat="server">
         <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
            <Services>
                <asp:ServiceReference Path="wajax.asmx"  />
            </Services>
        </asp:ScriptManager>
        <div>
            <div id="container"></div>
            <div class="ysa">
                返回：<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/fanhui.jpg" Height="80px" Width="80px" OnClick="ImageButton1_Click" />
                刷新：
                <img alt="" src="Images/shuaxing.jpg" width="80px" height="80px" onclick="javascript: window.location.reload();" />
                上一级节点： 
                <img alt="" src="Images/syj.jpg" width="80px" height="80px" onclick="javascript:xdd();" />
                返回总览：
                <img alt="" src="Images/ckqb.png" width="80px" height="80px" onclick="javascript:window.location.href='fullmap.aspx?pid=1&zm=8'" />
                <br />
                <br />
            </div>
        </div>
    </form>
</body>
</html>
<script type="text/javascript"
    src="http://webapi.amap.com/maps?v=1.2&key=ab5ae8097e26040fa604012b73e78f03">
</script>
<%--    <script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script> --%>
<script type="text/javascript">
    var ln;
    var point;
    var mapObj;
    var zom, pd,olduri;
    var toolBar, locationInfo;
    var myBoolean = false;
    var tool;
    function raa() {

        // x=   WebService.HelloWorld();
        //  alert("adda");
        //  x = ln.getLng();
        //  var y = ln.getlnt();
        alert(x);

    }
    function xdd() {
        //  $("#fm").attr("src", "dituxianshi.aspx");
        weba.wajax.pidbpid(pd, gopid);
        //  toolBar.doLocation()
        //  myBoolean = true;
    }
    function a() {
        //  weba.wajax.HelloWorld(onresult);
        x = ln.getLng();
        y = ln.getLat();
        weba.wajax.xiougai(x, y, '<%= Request.QueryString["id"] %>', onresult)

    }
    function gopid(result) {
       
        window.location.href="fullmap.aspx?pid="+result+"&zm="+(Number(zom)-3).toString();
    }
    function onresult(result) {
        alert(result);
    }
    function xh(rx, ry, d, nm, sm, ig, pdi) {

        if (sm.indexOf("中心点")>0 || pdi==pd) {
            var marker = new AMap.Marker({
                id: d,
                draggable: true,
                position: new AMap.LngLat(rx, ry),
                icon: "http://webapi.amap.com/images/0.png",
                offset: { x: -8, y: -34 }
            });// 创建点坐标
            mapObj.addOverlays(marker);

           /* var info = [];
            info.push("<img src='Images/" + ig + "'width='30' height='30'>");
            info.push("&nbsp;编号:" + d + sm + "<br  />");
            info.push("&nbsp;&nbsp;" + nm);

            var inforWindow = new AMap.InfoWindow({
                //offset: new AMap.Pixel(45, -34),
                offset: new AMap.Pixel(0, -23),
                content: info.join("")
            });
            AMap.event.addListener(marker, "click", function (e) {
                inforWindow.open(mapObj, marker.getPosition());
            });*/
            var markerContent = document.createElement("div");
            markerContent.className = "markerContentStyle";
            var markerImg = document.createElement("img");
            markerImg.className = "markerlnglat";
            markerImg.src = "http://webapi.amap.com/images/0.png";
            markerContent.appendChild(markerImg);
            var markerSpan = document.createElement("span");
            markerSpan.innerHTML = "<a href='fullmap.aspx?pid=" + d + "&zm=" + (Number(zom) + 3).toString() + "'>" + sm + "</a>";
            markerContent.appendChild(markerSpan);
            marker.setContent(markerContent);
         //   marker.setPosition(new AMap.LngLat(rx, ry));
            AMap.event.addListener(marker, "dragend", function (e) {
                var nx = e.lnglat.getLng();
                var ny = e.lnglat.getLat();
                if (confirm("确定要更新" + nm + "吗？")) {// alert();
                    weba.wajax.genxing(nx, ny, d, onresult)
                }
            });
        }
        else {


            var marker = new AMap.Marker({
                id: d,
                draggable: true,
                position: new AMap.LngLat(rx, ry),
                icon: "http://webapi.amap.com/images/marker_sprite.png",
                offset: { x: -8, y: -34 }
            });// 创建点坐标
            mapObj.addOverlays(marker);

            var info = [];
            info.push("<img src='Images/" + ig + "'width='30' height='30'>");
            info.push("&nbsp;编号:" + d + sm + "<br  />");
            info.push("&nbsp;&nbsp;" + nm);

            var inforWindow = new AMap.InfoWindow({
                //offset: new AMap.Pixel(45, -34),
                offset: new AMap.Pixel(0, -23),
                content: info.join("")
            });
            AMap.event.addListener(marker, "click", function (e) {
                inforWindow.open(mapObj, marker.getPosition());
            });
            AMap.event.addListener(marker, "dragend", function (e) {
                var nx = e.lnglat.getLng();
                var ny = e.lnglat.getLat();
                if (confirm("确定要更新" + nm + "吗？")) {// alert();
                    weba.wajax.genxing(nx, ny, d, onresult)
                }
            });
        }
    }
    function onresult(result) {
        alert(result);
    }
    function suc(result) {
        var ps = new AMap.LngLat(result[0].lx, result[0].ly);
        // alert(result.length);
        mapObj.setCenter(ps);
        mapObj.setZoom(zom);

        for (var i = 0; i < result.length; i++) {
            xh(result[i].lx, result[i].ly, result[i].Id, result[i].name, result[i].shuoming, result[i].tupianurl, result[i].pid);
            //var marker = new AMap.Marker({
            //    id: result.Id,
            //    position: new AMap.LngLat(result[i].lx, result[i].ly),
            //    icon: "http://webapi.amap.com/static/images/marker_sprite.png",
            //    offset: { x: -8, y: -34 }
            //});// 创建点坐标
            //mapObj.addOverlays(marker);

            //var info = [];
            //info.push("<b>&nbsp;&nbsp;" + result[i].name + "</b>");
            //info.push("&nbsp;&nbsp;" + result[i].shuoming);
            //info.push("&nbsp;&nbsp;" + result[i].Id);

            //var inforWindow = new AMap.InfoWindow({
            //    offset: new AMap.Pixel(45, -34),
            //    content: info.join("<br  />")
            //});
            //AMap.event.addListener(marker, "click", function (e) {
            //    inforWindow.open(mapObj, marker.getPosition());
            //});
        }

        //if (myBoolean == true)
        //{
        //    //  toolBar.doLocation()
        //    alert("a");
        //}
    }
    function initialize() {
        pd = '<%= Request.QueryString["pid"] %>'
        zom = '<%= Request.QueryString["zm"] %>'
        mapObj = new AMap.Map("container"); // 创建地图实例
        if (pd=="") {
            point = new AMap.LngLat(121.550331, 29.868038); // 创建点坐标
            mapObj.setCenter(point);
        }
        else {
            point = new AMap.LngLat(121.550331, 29.868038);
            mapObj.setCenter(point);
            weba.wajax.getbyid(pd, suc);
            
            //point = new AMap.LngLat(jd, wd);
            //var markera = new AMap.Marker({
            //    id: "m122",
            //    position: new AMap.LngLat(jd, wd),
            //    icon: "http://webapi.amap.com/static/images/marker_sprite.png",
            //    offset: { x: -8, y: -34 }
            //});// 创建点坐标
            //mapObj.addOverlays(markera);
        }

        //  alert(ln.getLng());
        mapObj.plugin(["AMap.ToolBar", "AMap.OverView,AMap.Scale"], function () {
            // 加载工具条
            tool = new AMap.ToolBar({
                direction: false, // 隐藏方向导航
                ruler: false, // 隐藏视野级别控制尺
                autoPosition: false // 禁止自动定位
            });
            mapObj.addControl(tool);

            // 加载鹰眼
            view = new AMap.OverView();
            mapObj.addControl(view);

            // 加载比例尺
            scale = new AMap.Scale();
            mapObj.addControl(scale);
        });
        // var point = new AMap.LngLat(116.404, 39.915); // 创建点坐标
        // 设置地图中心点坐标
        mapObj.plugin(["AMap.ToolBar"], function () {
            toolBar = new AMap.ToolBar(); //设置地位标记为自定义标记  
            mapObj.addControl(toolBar);
            AMap.event.addListener(toolBar, 'location', function callback(e) {
                locationInfo = e.lnglat;
            });
        });

        mapObj.bind(mapObj, "click", function (e) {
            ln = e.lnglat;
            var markera = new AMap.Marker({
                id: "m123",
                position: e.lnglat,
                icon: "http://webapi.amap.com/images/marker_sprite.png",
                offset: { x: -8, y: -34 }
            });
            //  alert(ln.getLng());
            mapObj.addOverlays(markera);
            mapObj.setCenter(ln);

        });
    }

</script>

